<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <!-- 导入样式模板 -->
  {{include './header.html'}}
  <main>
    {{if status}}
      <p>{{msg}},2秒后进入登陆页面</p>
      <script>
        setTimeout(() => {
          location.href='/login'
        }, 2000);
      </script>
    {{else}}
    <div class="container">
      <form action="/api/register" method='post'>
        <div class="form-group">
          <label for="account">账号：</label>
          <input type="text" class="form-control" id="account" name='account' placeholder="请输入账号" pattern='^[a-zA-Z]{1,6}$'>
        </div>
        <div class="form-group">
          <label for="pwd">密码：</label>
          <input type="password" class="form-control" id="pwd" placeholder="Password" name='pwd' pattern="^[0-9]{1}$">
        </div>
        <div class="form-group">
          <label for="repwd">确认密码：</label>
          <input type="password" class="form-control" id="repwd" placeholder="Password" name='repwd'>
        </div>
        <div class="form-group">
          <label for="email">邮箱:</label>
          <input type="email" class="form-control" id="email" placeholder="请输入邮箱" name='email'>
        </div>
        <button type="submit" class="btn btn-success form-control">注册</button>
      </form>
    </div>
    <script>
      document.forms[0].onsubmit=function(e){
        var password=$('input:password').map((i,item)=>{
          return $(item).val()
        })
        if(password[0]!=password[1]){
          e.preventDefault();
          alert('两次密码输入不一致')
        }
    
      }
    </script>
    {{/if}}
  </main>
  
</body>
</html>